﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AircraftCarrier.Lib
{
    public class TradeHandle
    {
        public  double curPrice;
        private double setting_up;
        private double setting_down;
        public double default_setting_up = 0.05;
        public double default_setting_down = 0.05;
        public TradeHandle()
        {
            curPrice = 0;
            setting_down = default_setting_up;
            setting_up = default_setting_up;
        }
        public TradeHandle(double up, double down)
        {
            curPrice = 0;
            setting_down = down;
            setting_up = up;
        }
        public ResultEnum Process(double newPrice)
        {
            if (curPrice != 0)
            {
                if (newPrice - curPrice >= setting_up)
                {
                    curPrice = newPrice;
                    return ResultEnum.Up;
                }
                if (curPrice - newPrice >= setting_down)
                {
                    curPrice = newPrice;
                    return ResultEnum.Down;
                }
                return ResultEnum.Stay;
            }
            else
            {
                curPrice = newPrice;
                return ResultEnum.Stay;
            }
        }
    }
}
